<div class="row">
  <div class="col-md-12">
    <%= link_to "Clean Cart", clean_carts_path,
                method: :delete, class: "pull-right", style: "text-decoration: underline;",
                data: { confirm: "Are you sure?"} %>


    <h2> Cart </h2>

    <table class="table table-borded">
      <thead>
        <tr>
          <th colspan="2">Product Info</th>
          <th>Price</th>
          <th>Quantity</th>
          <th>Options</th>
        </tr>
      </thead>
      <tbody>
        <% current_cart.cart_items.each do |cart_item| %>
          <tr>
            <td>
              <%= link_to product_path(cart_item.product) do %>
                <% if cart_item.product.image.present? %>
                  <%= image_tag(cart_item.product.image.thumb.url, class: "thumbnail") %>
                <% else %>
                  <%= image_tag("http://placehold.it/100x100&text=No Pic", class: "thumbnail") %>
                <% end %>
              <% end %>
            </td>
            <td> <%= link_to cart_item.product.title, product_path(cart_item.product)%></td>
            <td> <%= cart_item.product.price %> </td>
            <td>
              <%= form_for cart_item, url: cart_item_path(cart_item.product_id) do |f| %>
                <%= f.select :quantity, 1..cart_item.product.quantity %>
                <%= f.submit "Update", data: { disable_with: "Submitting..."} %>
              <% end %>
            </td>
            <td>
              <%= link_to cart_item_path(cart_item.product_id), method: :delete do %>
                <i class="fa fa-trash"></i>
              <% end %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <hr>

    <div class="checkout clearfix">
      <%= link_to("Billing Now", checkout_carts_path, method: :post, class: "btn btn-lg btn-danger") %>
      <span class="pull-right">
        Total: <%= render_cart_total_price(current_cart) %> 
      </span>
    </div>

  </div>
</div>
